package com.tarena.lbs.activity.controller;

import com.tarena.lbs.activity.pojo.query.ActivityQuery;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.BasePageQuery;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.activity.service.ActivityService;
import com.tarena.lbs.activity.pojo.param.ActivityAddParam;
import com.tarena.lbs.activity.pojo.vo.ActivityVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * 活动相关功能接口
 */
@Slf4j
@Api(tags = "活动相关功能接口")
@RestController
public class ActivityController {

    @Autowired
    private ActivityService activityService;


    @ApiOperation("商家活动列表")
    @PostMapping("/admin/marketing/marketingActivity/info/list")
    public Result<PageResult<ActivityVO>> pageList(@RequestBody ActivityQuery activityQuery)
        throws BusinessException {
        PageResult<ActivityVO> result = activityService.selectActivityList(activityQuery);
        return new Result("0","查询活动列表",result);
    }

    /*
    * 添加活动
    * */
  /*
   @ApiOperation("商家活动保存")
    @PostMapping("/admin/marketing/marketingActivity/info/save")
    public Result<Void> activitySave(@RequestBody ActivityAddParam param) {
        activityService.saveActivity(param);
        return Result.success();
    }
    */
    @ApiOperation("商家活动详情")
    @GetMapping("/admin/marketing/marketingActivity/info/detail/{id}")
    public Result<ActivityVO> activityDetail(@PathVariable("id") Integer id)
        throws BusinessException {
        if (id == null || id <= 0) {
            throw new RuntimeException("活动ID不合法");
        }

        // 调用Service层获取活动详情
        ActivityVO activityVO = activityService.getActivityDetailById(id);

        return new Result(activityVO);
    }

}
